﻿package mortal.game.view.forging
{
    import __AS3__.vec.*;
    import com.gengine.utils.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.view.common.util.*;

    public class EquipBasePropUtil extends Object
    {
        private var propsMap:HashMap;
        private static var _instance:EquipBasePropUtil;

        public function EquipBasePropUtil()
        {
            this.propsMap = new HashMap();
            if (_instance != null)
            {
                throw new Error(" EquipBasePropUtil 单例 ");
            }
            this.init();
            return;
        }// end function

        private function init() : void
        {
            this.propsMap.push("attack", GameDefConfig.instance.getAttributeName("attack", false, 1));
            this.propsMap.push("life", GameDefConfig.instance.getAttributeName("life", false, 1));
            this.propsMap.push("mana", GameDefConfig.instance.getAttributeName("mana", false, 1));
            this.propsMap.push("physDefense", GameDefConfig.instance.getAttributeName("physDefense", false, 1));
            this.propsMap.push("magicDefense", GameDefConfig.instance.getAttributeName("magicDefense", false, 1));
            this.propsMap.push("penetration", GameDefConfig.instance.getAttributeName("penetration", false, 1));
            this.propsMap.push("crit", GameDefConfig.instance.getAttributeName("crit", false, 1));
            this.propsMap.push("toughness", GameDefConfig.instance.getAttributeName("toughness", false, 1));
            this.propsMap.push("hit", GameDefConfig.instance.getAttributeName("hit", false, 1));
            this.propsMap.push("jouk", GameDefConfig.instance.getAttributeName("jouk", false, 1));
            this.propsMap.push("expertise", GameDefConfig.instance.getAttributeName("expertise", false, 1));
            this.propsMap.push("block", GameDefConfig.instance.getAttributeName("block", false, 1));
            this.propsMap.push("damageReduce", GameDefConfig.instance.getAttributeName("damageReduce", false, 1));
            return;
        }// end function

        public function getStrengthenProps(param1:ItemEquipInfo, param2:Number, param3:Number, param4:Number) : Array
        {
            var _loc_6:int = 0;
            var _loc_8:String = null;
            var _loc_9:Object = null;
            var _loc_5:Array = [];
            var _loc_7:* = this.propsMap.keys;
            for each (_loc_8 in _loc_7)
            {
                
                if (param1[_loc_8] != 0)
                {
                    _loc_9 = {};
                    _loc_9.propName = this.propsMap.getValue(_loc_8);
                    _loc_9.propValue = int(int(param1[_loc_8] * param4) * param2);
                    _loc_9.propUpValue = int(int(param1[_loc_8] * param4) * param3);
                    _loc_5.push(_loc_9);
                    _loc_6++;
                    if (_loc_6 == 3)
                    {
                        break;
                    }
                }
            }
            return _loc_5;
        }// end function

        public function getStrengthenProps2(param1:ItemData) : Array
        {
            var _loc_5:Object = null;
            var _loc_2:Array = [];
            var _loc_3:* = EquipmentUtil.getStrengthenAttr(param1);
            var _loc_4:int = 0;
            while (_loc_4 < _loc_3.length)
            {
                
                _loc_5 = {};
                _loc_5.attrName = _loc_3[_loc_4].name;
                _loc_5.propName = GameDefConfig.instance.getAttributeName2(_loc_3[_loc_4].name);
                _loc_5.propBaseValue = _loc_3[_loc_4].attrBaseValue;
                _loc_5.propStrengValue = _loc_3[_loc_4].value;
                _loc_2.push(_loc_5);
                _loc_4++;
            }
            return _loc_2;
        }// end function

        public static function get instance() : EquipBasePropUtil
        {
            if (_instance == null)
            {
                _instance = new EquipBasePropUtil;
            }
            return _instance;
        }// end function

    }
}
